package com.guldan.core.search;

/**
 * Created by Silas.
 * Date: 2016/10/1
 * Time: 22:19
 */
import com.guldan.core.search.Searchable;
import java.io.Serializable;

public class PagingSearchable implements Searchable, Serializable {
    public static final int MAX_PAGE = 999999999;
    private Integer currentPage = Integer.valueOf(1);
    private Integer perPage = Integer.valueOf(10);
    private boolean paging = true;
    private String orderByClause;
    private int offset;

    public PagingSearchable() {
    }

    public Integer getCurrentPage() {
        return this.currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getPerPage() {
        return this.perPage;
    }

    public void setPerPage(Integer perPage) {
        this.perPage = perPage;
    }

    public Integer getBegin() {
        return this.isPaging()?Integer.valueOf((this.currentPage.intValue() - 1) * this.perPage.intValue() + this.offset):Integer.valueOf(0);
    }

    public boolean isPaging() {
        return this.paging;
    }

    public void setPaging(boolean paging) {
        this.paging = paging;
    }

    public String getOrderByClause() {
        return this.orderByClause;
    }

    public void setOrderByClause(String orderByClause) {
        this.orderByClause = orderByClause;
    }

    public int getOffset() {
        return this.offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }
}
